package com.crr.controller;

import com.crr.bean.Car;
import com.crr.common.bean.ResultBean;
import com.crr.common.controller.BaseController;
import com.crr.service.CarService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/v1")
@Api(tags = "加入购物车")
public class CarController extends BaseController {

    @Autowired
    CarService carService;

    @PostMapping("/car")
    public ResultBean addCar(@RequestBody Car car) {
        carService.addcar(car);
        return success("加入购物车");
    }

    @GetMapping("/car")
    public ResultBean getCar() {
        List list = carService.getCarList();
        return success("购物车", list);
    }
}